package cn.bonoon.entities.interacting;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import cn.bonoon.kernel.io.AbstractStoragePersistable;
import cn.bonoon.kernel.io.DirectoryStrategy;
import cn.bonoon.kernel.io.StorageCatalog;

/**
 * 公告信息，允许公告带一个附件
 * 
 * @author jackson
 * 
 */
@Entity
@Table(name = "t_announcement")
@StorageCatalog(
		title = "公告附件", 
		folders = {"sys", "announcement"}, 
		directoryStrategy = DirectoryStrategy.YEAR,
		reversed = true)
public class AnnouncementEntity extends AbstractStoragePersistable{

	private static final long serialVersionUID = 7263730958556062396L;
	
	@OneToMany(mappedBy = "announcement")
	private List<AnnouncementReleaseEntity> releases;

	@Column(name = "C_CONTENT", length = 2048)
	private String content;

	/**
	 * <pre>
	 * 公告的类型：
	 * 0-外部公告（不需要登录都可以查看）
	 * 1-内部公告（只有登录系统才能查看）
	 * 2...n - 由子系统自行定义
	 * </pre>
	 */
	@Column(name = "C_TYPE")
	private int type;
	
	/** 该公告属于哪个系统
	 * @deprecated 以后这个字段是作废的 */
	@Column(name = "C_KEY")
	private String key;

	/** 是否发布在平台；如果是，则任何人登录后在平台的首页都可以看到 */
	@Column(name = "C_PLATFORM")
	private boolean platform;
	
	@Column(name = "C_OWNERID")
	private long ownerId;

	@Column(name = "C_DISABLE")
	private boolean disable;
	
	/** 是否置顶 */
	@Column(name = "C_TOPEST")
	private boolean topest;

	/** 置顶指定的时间，如：2017-1-1号之前，这里的计算是不包含2017-1-1号当前的 */
	@Temporal(TemporalType.DATE)
	@Column(name = "C_TOPTO")
	private Date topTo;

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

//	public Long getCreatorId() {
//		return creatorId;
//	}
//
//	public void setCreatorId(Long creatorId) {
//		this.creatorId = creatorId;
//	}
//
//	public Date getCreateAt() {
//		return createAt;
//	}
//
//	public void setCreateAt(Date createAt) {
//		this.createAt = createAt;
//	}
//
//	public String getCreatorName() {
//		return creatorName;
//	}
//
//	public void setCreatorName(String creatorName) {
//		this.creatorName = creatorName;
//	}

	public long getOwnerId() {
		return ownerId;
	}

	public void setOwnerId(long ownerId) {
		this.ownerId = ownerId;
	}

	public boolean isDisable() {
		return disable;
	}

	public void setDisable(boolean disable) {
		this.disable = disable;
	}

//	public boolean isDeleted() {
//		return deleted;
//	}
//
//	public void setDeleted(boolean deleted) {
//		this.deleted = deleted;
//	}

	public boolean isPlatform() {
		return platform;
	}

	public void setPlatform(boolean platform) {
		this.platform = platform;
	}

	public List<AnnouncementReleaseEntity> getReleases() {
		return releases;
	}

	public void setReleases(List<AnnouncementReleaseEntity> releases) {
		this.releases = releases;
	}

//	public boolean isTopMost() {
//		return topMost;
//	}
//
//	public void setTopMost(boolean topMost) {
//		this.topMost = topMost;
//	}

	public Date getTopTo() {
		return topTo;
	}

	public void setTopTo(Date topTo) {
		this.topTo = topTo;
	}

	public boolean isTopest() {
		return topest;
	}

	public void setTopest(boolean topest) {
		this.topest = topest;
	}

}
